function [sj_out, p_out] = new_eq_CT(p_nt,mc_update,theta2,ns,ind_market,x2,sales_tax, delta, A1, QI,tier,cat,year)
sel_mrkt=ind_market(year>=2019);
% 
options = optimset('Algorithm','sqp','GradObj', ...
'off','GradCon','off','DerivativeCheck','off', 'maxiter', 4000,...
'MaxFunEvals', 1000000,'TolFun',1e-08,'TolX',1e-8);

v_c=getranddraw(length(theta2)-1, ns);
p_out=p_nt./1000;
expmu1=expmu(theta2,v_c,x2,p_out);
sj_out=mktshares(delta,expmu1,QI,ind_market);


parfor ii=min(sel_mrkt):max(sel_mrkt)
    ii
    temp=find(ind_market==ii);
    ind_market_i=ind_market(temp);
    delta_i=delta(temp);
    mc_i=mc_update(temp);
    p_cf_i=p_nt(temp)./1000;
    A1_i=A1(temp,temp);
    x2_i=x2(temp,:);
    cf_salestax_i=sales_tax(temp,:);
    cat_i=cat(temp,:);
    tier_i=tier(temp,:);
    QI_i=QI(temp,:);
    tic
    [p_1,fval]=fmincon(@(p0)new_pr_CT(p0,delta_i,mc_i,A1_i,x2_i,theta2,v_c,cf_salestax_i,cat_i,tier_i),p_cf_i,[], [], [], [], ...
    [],[],[], options);
    toc
    
    p_2{ii}=(p_1.*(1+cf_salestax_i+tier_i))+cat_i./1000;
    expmu2=expmu(theta2,v_c,x2_i,p_2{ii});
    s_2{ii}=mktshares(delta_i,expmu2,QI_i,ind_market_i);
end
for jj=min(sel_mrkt):max(sel_mrkt)
    temp2=find(ind_market==jj);
    p_out(temp2)=p_2{jj};
    sj_out(temp2)=s_2{jj};
end

end% function computing counterfactual price equilibrium  

